Skip to content

Send chat streams through the install's signed CloudFront path - #353

Merged
nambok merged 1 commit into
mainfrom
fix/stream-through-cloudfront
Nov 10, 2026
Merged

nambok merged 1 commit into
mainfrom
fix/stream-through-cloudfront

Conversation

@nambok

@nambok nambok commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Self-hosted installs are moving their streaming function URL off the public internet (AWS Security Hub Lambda.1, critical): the URL takes only calls CloudFront signs with origin access control (CoderHelm/coderhelm-platform, fix/security-hub). CloudFront's signature is the Authorization header, and Lambda refuses a signed POST without its body hash, so the dashboard has to send the stream token and the body differently on the install's own hostname.

Changes

  • src/lib/stream-client.ts: streamPost(token, payload) builds a stream POST. On the dashboard's own hostname (streamUrl is "", a self-hosted install) it sends the token in x-coderhelm-stream-token and the body's SHA-256 (hex, over the exact UTF-8 bytes sent) in x-amz-content-sha256, with no Authorization. On another hostname (the hosted service) it sends Authorization: Bearer as before, so its cross-origin preflight is unchanged.
  • The plan chat stream and the chat answer stream (src/lib/brain.ts) both use it.
  • e2e/chat.spec.ts: the self-hosted request carries the token header and a hash equal to SHA-256 of its body, with no Authorization; the other-hostname request carries only the bearer token.

Verification

  • npx tsc --noEmit: no errors. npm run lint: passes.
  • playwright test e2e/chat.spec.ts e2e/audit-plans.spec.ts e2e/agent-permissions.spec.ts: 68 passed, the 2 new ones included.
  • crypto.subtle SHA-256 over TextEncoder bytes checked against Node's createHash on non-ASCII text.
  • The gateway accepts the new header and falls back to the bearer token (platform PR), so this works against both the old and the new streaming setup.

On a self-hosted install the streaming function's URL now takes only calls
CloudFront signs (origin access control). CloudFront's signature is the
Authorization header and Lambda needs a signed POST's body hash, so a stream
on the dashboard's own hostname sends the token in x-coderhelm-stream-token
and the body's SHA-256 in x-amz-content-sha256. A stream on another hostname
keeps the bearer token.
@nambok
nambok merged commit a95516a into main Nov 10, 2026
10 checks passed
@nambok
nambok deleted the fix/stream-through-cloudfront branch November 10, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant